package com.community.backend.controller;

import com.community.backend.pojo.Interaction;
import com.community.backend.pojo.dto.InteractionQueryDTO;
import com.community.backend.service.InteractionService;
import com.community.backend.utils.PageResult;
import com.community.backend.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/interaction")
public class InteractionController {

    private final InteractionService interactionService;
    public InteractionController(InteractionService interactionService) {
        this.interactionService = interactionService;
    }
    @GetMapping("/page")
    public Result<PageResult> page(InteractionQueryDTO interactionQueryDTO) {
        PageResult pageResult = interactionService.pageQuery(interactionQueryDTO);
        return Result.success(pageResult);
    }
    @PostMapping
    public Result add(Interaction interaction) {
        interactionService.add(interaction);
        return Result.success();
    }

    /**
     * 逻辑删除
     * @param id
     * @return
     */
    @PutMapping ("/{id}")
    public Result deleteById(@PathVariable Integer id) {
        interactionService.deleteById(id);
        return Result.success();
    }
    @PutMapping
    public Result update(Interaction interaction) {
        interactionService.update(interaction);
        return Result.success();
    }
}
